﻿using AdverseEventReportSystem.BLL;
using AdverseEventReportSystem.BLL.SchedulingSystem;
using AdverseEventReportSystem.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AdverseEventReportSystem.Web.Areas.Scheduling.Controllers
{
    public class SchedulingPersonnelController : BaseController
    {
        //
        // GET: /Scheduling/SchedulingPersonnel/
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 排班人员列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Search()
        {
            SchedulingSystemSoapClient service = new SchedulingSystemSoapClient();
            ResultHelperOfListOfGetSchedulingPersonnelInfor serviceResult = service.GetSchedulingPersonnel(loginUser.CurrDepCode);
            GetSchedulingPersonnelInfor[] list = null;
            if (serviceResult.S)
            {
                list = serviceResult.D;
            }
            var result = new { Rows = list };
            return JsonDate(result);
        }

        /// <summary>
        /// 保存排班人员
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Save(SchedulingPersonnel[] personnelList)
        {
            OperateResult resultInfo = SchedulingPersonnelManager.Save(personnelList);
            return JsonDate(resultInfo);
        }

        /// <summary>
        /// 删除排班人员
        /// </summary>
        /// <returns></returns>
        public ActionResult Delete()
        {
            OperateResult resultInfo = SchedulingPersonnelManager.Del(loginUser.CurrDepCode);
            return JsonDate(resultInfo);
        }
	}
}